
package ch.hearc.meteo.tools;

import java.awt.Image;
import java.awt.Toolkit;
import java.net.URL;

import javax.swing.ImageIcon;

public class ImageTools
	{

	/*------------------------------*\
	|*			  Static			*|
	\*------------------------------*/

	/*------------------------------------------------------------------*\
	|*							Methodes Public							*|
	\*------------------------------------------------------------------*/

	/**
	 * extension : .png or .jpg
	 */
	public static Image loadJar(String filename, boolean isBlocking)
		{
		return loadIconJar(filename, isBlocking).getImage();
		}

	/*------------------------------------------------------------------*\
	|*							Methodes Private						*|
	\*------------------------------------------------------------------*/

	/**
	 * extension : .png ou .jpg
	 */
	private static ImageIcon loadIconJar(String filename, boolean isBlocking)
		{
		URL url = ClassLoader.getSystemResource(filename);

		if (!isBlocking)
			{
			return new ImageIcon(Toolkit.getDefaultToolkit().getImage(url));
			}
		else
			{
			return new ImageIcon(url);
			}
		}
	}
